package com.sinothk.fc.supplier.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sinothk.fc.supplier.entity.SupplierSearchKeyword;
import com.sinothk.fc.supplier.service.ISupplierSearchKeywordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Description: 供应商搜索关键字
 * @Author: Liangyt
 * @Date: 2022-08-13
 * @Version: V1.0
 */
@Api(tags = "供应商搜索关键字")
@RestController
@RequestMapping("/fc/supplier/searchKeywordCtrl")
@Slf4j
public class SupplierSearchKeywordController {

    @Autowired
    private ISupplierSearchKeywordService supplierSearchKeywordService;

    /**
     * 添加
     *
     * @param supplierSearchKeyword
     * @return
     */
    @AutoLog(value = "供应商搜索关键字-添加")
    @ApiOperation(value = "供应商搜索关键字-添加", notes = "供应商搜索关键字-添加")
    @PostMapping(value = "/add")
    public Result<?> add(@RequestBody SupplierSearchKeyword supplierSearchKeyword) {
        supplierSearchKeywordService.add(supplierSearchKeyword);
        return Result.OK("添加成功！");
    }

    /**
     * 分页列表查询
     *
     * @param district
     * @return
     */
    @AutoLog(value = "供应商搜索关键字-分页列表查询")
    @ApiOperation(value = "供应商搜索关键字-分页列表查询", notes = "供应商搜索关键字-分页列表查询")
    @GetMapping(value = "/searchKeywordList")
    public Result<?> searchKeywordList(@RequestParam(name = "district", required = false) String district) {
        IPage<SupplierSearchKeyword> pageList = supplierSearchKeywordService.searchKeywordList(new Page<SupplierSearchKeyword>(1, 10), district);
        return Result.OK(pageList.getRecords());
    }
}
